
if (SERVER) then

	SWEP.HoldType			= "smg"
	SWEP.Weight				= 5
	SWEP.AutoSwitchTo		= false
	SWEP.AutoSwitchFrom		= false
	
	AddCSLuaFile( "shared.lua" )
	
end

if ( CLIENT ) then

	SWEP.DrawAmmo			= false
	SWEP.DrawCrosshair		= true
	
	SWEP.ViewModelFlip		= false
	SWEP.CSMuzzleFlashes	= true

	SWEP.PrintName			= "Base_PF_SWEP"			

	SWEP.Slot				= 2
	SWEP.SlotPos			= 2
	SWEP.ViewModelFOV		= 70
	SWEP.IconLetter			= "x"
	
	surface.CreateFont("csd", ScreenScale(30), 500, true, true, "CSKillIcons")
	surface.CreateFont("csd", ScreenScale(60), 500, true, true, "CSSelectIcons")
	//killicon.AddFont( "weapon_ts_base", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )

end

SWEP.Author			= "Rambo_6"
SWEP.Contact		= ""
SWEP.Purpose		= ""
SWEP.Instructions	= ""

SWEP.Spawnable			= false
SWEP.AdminSpawnable		= false

SWEP.Primary.Sound			= Sound("Weapon_aug.Single")
SWEP.Primary.Recoil			= 1
SWEP.Primary.Damage			= 1
SWEP.Primary.VehDamageScale = 1
SWEP.Primary.NumShots		= 1
SWEP.Primary.Cone			= 0.2
SWEP.Primary.Delay			= 0.2

SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo			= "none"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"
 
 /*---------------------------------------------------------
   Name: SWEP:Init( )
   Desc: Pull out your gun
---------------------------------------------------------*/
function SWEP:Initialize()
	if ( SERVER ) then
		self:SetWeaponHoldType( self.HoldType )
	end
	self.Weapon:SendWeaponAnim( ACT_VM_DRAW );
end

/*---------------------------------------------------------
   Name: SWEP:PrimaryAttack( )
   Desc: +attack1 has been pressed
---------------------------------------------------------*/
function SWEP:PrimaryAttack()

	if ( !self:CanPrimaryAttack() ) then return end
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )

	if ( self.Weapon:Clip1() <= 0 ) then
		self.Weapon:DefaultReload( ACT_VM_RELOAD );
		self.Reloader = true
		self.Weapon:EmitSound(self.Primary.RSound,100,math.random(90,100))
	end
	
	self.Reloader = false
	
	local effectdata = EffectData()
		effectdata:SetOrigin( self.Owner:GetShootPos() )
		effectdata:SetEntity( self.Weapon )
		effectdata:SetStart( self.Owner:GetShootPos() )
		effectdata:SetNormal( self.Owner:GetAimVector() )
		effectdata:SetAttachment( 1 )
	util.Effect( "gunsmoke", effectdata )
	
	self:ShootBullet( self.Primary.NumShots, self.Primary.Damage, self.Primary.Sound, self.Primary.Cone, self.Primary.Recoil )
	
end

function SWEP:GetMaxAmmo()
	return self.Primary.ClipSize or 1
end

/*---------------------------------------------------------
   Name: SWEP:ShootBullet( )
   Desc: Fire Bullets
---------------------------------------------------------*/
function SWEP:ShootBullet( numbul, dmg, snd, cone, kick )

	if numbul == 0 then return end
	
	cone = cone or 0.01

	self.Weapon:GetOwner():EmitSound( snd,100,math.random(90,110) )
	self:ShootBulletEx( dmg, numbul, cone )
	self.Owner:ViewPunch( Angle( math.Rand(-0.9,-0.5) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )
	// Modified viewpunch to suit the weapons.
	
	self:TakePrimaryAmmo(1)
	
end

/*---------------------------------------------------------
   Name: SWEP:ShootBullet( )
   Desc: A convenience func to shoot bullets
---------------------------------------------------------*/
function SWEP:ShootBulletEx( damage, num_bullets, aimcone)
	
	local bullet = {}
	bullet.Num 		= num_bullets
	bullet.Src 		= self.Owner:GetShootPos()			// Source
	bullet.Dir 		= self.Owner:GetAimVector()			// Dir of bullet
	bullet.Spread 	= Vector( aimcone, aimcone, 0 )		// Aim Cone
	bullet.Tracer	= 6						// Show a tracer on every x bullets 
	bullet.Force	= 11								// Amount of force to give to phys objects
	bullet.Damage	= damage
	bullet.AmmoType = "Pistol"
	bullet.TracerName 	= "Tracer"
	bullet.Callback = function ( attacker, tr, dmginfo ) 
		if tr.Entity:IsValid() then
			if string.find(tr.Entity:GetClass(), "vehicle") then
				dmginfo:SetDamage(math.Clamp(math.Round(dmginfo:GetDamage()*(self.Primary.VehDamageScale or .8)), 1, 9000))
			end
		end
	end
	
	self.Owner:FireBullets( bullet )
	
	self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) 		// View model animation
	self.Owner:MuzzleFlash()							// Crappy muzzle light
	self.Owner:SetAnimation( PLAYER_ATTACK1 )			// 3rd Person Animation
	
end

/*---------------------------------------------------------
   Name: SWEP:Reload( )
   Desc: Reload is being pressed
---------------------------------------------------------*/
function SWEP:Reload()
	if self.Reloader == true then return true end
	self.Weapon:DefaultReload( ACT_VM_RELOAD );
	self.Reloader = true
	self.Weapon:EmitSound(self.Primary.RSound,100,math.random(90,100))
return true end


/*---------------------------------------------------------
   Name: SWEP:Think( )
   Desc: Called every frame
---------------------------------------------------------*/
function SWEP:Think()
end


/*---------------------------------------------------------
   Name: SWEP:Holster( weapon_to_swap_to )
   Desc: Weapon wants to holster
   RetV: Return true to allow the weapon to holster
---------------------------------------------------------*/
function SWEP:Holster( wep )
	return true
end

/*---------------------------------------------------------
   Name: SWEP:Deploy( )
   Desc: Whip it out
---------------------------------------------------------*/
function SWEP:Deploy()
	return true
end


